package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.EmployeeRole;
import cn.wolfcode.car.domain.Permission;
import cn.wolfcode.car.mapper.EmployeeRoleMapper;
import cn.wolfcode.car.qo.EmployeeRoleQueryObject;
import cn.wolfcode.car.service.IEmployeeRoleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class IEmployeeRoleServiceImpl implements IEmployeeRoleService {

    @Autowired
    private EmployeeRoleMapper employeeRoleMapper;

    @Override
    public int delete(Long id) {
        return 0;
    }

    @Override
    public int save(EmployeeRole record) {
        return employeeRoleMapper.insert(record);
    }

    @Override
    public EmployeeRole get(Long id) {
        return null;
    }

    @Override
    public PageInfo<EmployeeRole> list(EmployeeRoleQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<EmployeeRole> list = employeeRoleMapper.selectForPage(qo);
        return new PageInfo<>(list);
    }

    @Override
    public List<EmployeeRole> listAll() {
        return employeeRoleMapper.selectAll();
    }

    @Override
    public int update(EmployeeRole record) {
        return 0;
    }

    @Override
    public void deleteByEmployeeId(Long id) {
        employeeRoleMapper.deleteByEmployeeId(id);
    }

    @Override
    public List<Permission> getPermission(Long id) {
        return null;
    }
}
